package org.bdware.bdoa.authentication.serviceImpl;

import com.nimbusds.jose.jwk.RSAKey;
import org.bdware.bdoa.authentication.JwtConfig;
import org.bdware.bdoa.authentication.service.JwtService;
import org.bdware.bdoa.authentication.utils.JwxUtils;

//基于非对称加密来生成和解析JWT令牌
public class JwsServiceImpl implements JwtService {

    private JwtConfig jwtConfig;

    private RSAKey rsaKey;

    public JwsServiceImpl(JwtConfig jwtConfig) {
        this.jwtConfig = jwtConfig;
    }

    @Override
    public Object genKey() {
        return null;
    }

    @Override
    public String sign(String payload) {
        return null;
    }

    @Override
    public String verify(String publicKeyStr, String token) {
        return null;
    }

    @Override
    public String verify(String publicKeyStr, String source, String token) {
        boolean verified = new JwxUtils().verify(source,token, publicKeyStr);
        if(verified)
            return "验证成功";
        return "验证失败";
    }
}